package ar.edu.caece.dns;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.ResourceBundle;

/**
 * Clase para acceder a las propiedades de la aplicacion.
 * <p>
 * Implementada bajo modelo singleton.
 * 
 * @author Portillol
 * 
 */
public class PropertiesReader {

	private static PropertiesReader instancia;

	// private ResourceBundle resourceBundle;

	public static final String NOMBRE = "aplicacion.properties";

	private Properties properties;

	public static PropertiesReader getInstancia() {

		if (instancia == null)
			instancia = new PropertiesReader();

		return instancia;
	}

	private PropertiesReader() {
		// resourceBundle = ResourceBundle.getBundle("aplicacion");
		String filePath = System.getProperty("user.dir") + File.separator
				+ "conf" + File.separator;

		File rootFile = new File(filePath + NOMBRE);

		properties = new Properties();

		try {

			properties.load(new FileInputStream(rootFile));

		} catch (FileNotFoundException fnfe) {

			fnfe.printStackTrace();

		} catch (IOException ioe) {

			ioe.printStackTrace();
		}
	}

	public String getProperty(String name) {
		return (String) properties.getProperty(name);
	}
}
